package org.jsola.hr.helper;

import org.jsola.common.ClassKit;
import org.jsola.common.SafeKit;
import org.jsola.hr.dto.TreatmentDisposeEventAddDTO;
import org.jsola.hr.dto.TreatmentDisposeEventUpdateDTO;
import org.jsola.hr.entity.TreatmentDisposeEventDO;
import org.jsola.hr.query.TreatmentDisposeEventQuery;
import org.jsola.hr.service.ITreatmentDisposeEventService;
import org.jsola.hr.vo.TreatmentDisposeEventVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Date;
import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 待遇处理事件
 *
 * @author zhr
 */
@Component
public class TreatmentDisposeEventTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITreatmentDisposeEventService treatmentDisposeEventService;

    /**
     * 生成add测试数据
     * @return TreatmentDisposeEventAddDTO
     */
    public TreatmentDisposeEventAddDTO getTreatmentDisposeEventAddDTO(){
        TreatmentDisposeEventAddDTO treatmentDisposeEventAddDTO = new TreatmentDisposeEventAddDTO();
        treatmentDisposeEventAddDTO.setTemplateId(getRandomValue("varchar",32));
        treatmentDisposeEventAddDTO.setEventType(getRandomValue("varchar",32));
        treatmentDisposeEventAddDTO.setCurrentWorkflow(getRandomValue("varchar",50));
        treatmentDisposeEventAddDTO.setTakeOrdersUserId(getRandomValue("varchar",32));
        treatmentDisposeEventAddDTO.setTakeOrdersUserName(getRandomValue("varchar",50));
        treatmentDisposeEventAddDTO.setTakeOrdersDate((Date)ClassKit.getObjectValue(getRandomValue("datetime",0),"java.util.Date"));
        treatmentDisposeEventAddDTO.setIsPrecedence(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        treatmentDisposeEventAddDTO.setIsFinish(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        treatmentDisposeEventAddDTO.setFinishDate((Date)ClassKit.getObjectValue(getRandomValue("datetime",0),"java.util.Date"));
        treatmentDisposeEventAddDTO.setEmpId(getRandomValue("varchar",32));
        treatmentDisposeEventAddDTO.setEmpName(getRandomValue("varchar",50));
        treatmentDisposeEventAddDTO.setEmpIdCard(getRandomValue("varchar",20));
        treatmentDisposeEventAddDTO.setCompanyId(getRandomValue("varchar",32));
        treatmentDisposeEventAddDTO.setCompanyName(getRandomValue("varchar",100));
        treatmentDisposeEventAddDTO.setWorkCity(getRandomValue("varchar",50));
        return treatmentDisposeEventAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TreatmentDisposeEventUpdateDTO
     */
    public TreatmentDisposeEventUpdateDTO getTreatmentDisposeEventUpdateDTO(TreatmentDisposeEventVO treatmentDisposeEventVO){
        return treatmentDisposeEventService.selectDOById(treatmentDisposeEventVO.getId(), SITE_ID).to(TreatmentDisposeEventUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TreatmentDisposeEventQuery
     */
    public TreatmentDisposeEventQuery getTreatmentDisposeEventQuery() {
        TreatmentDisposeEventQuery treatmentDisposeEventQuery = new TreatmentDisposeEventQuery();
        List<TreatmentDisposeEventDO> treatmentDisposeEventDOList = treatmentDisposeEventService.list(new TreatmentDisposeEventDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(treatmentDisposeEventDOList)) {
            TreatmentDisposeEventDO treatmentDisposeEventDO = treatmentDisposeEventDOList.get(0);
            treatmentDisposeEventQuery = treatmentDisposeEventDO.to(TreatmentDisposeEventQuery.class);
        }
        return treatmentDisposeEventQuery;
    }

    /**
     * 保存示例
     * @return TreatmentDisposeEventVO
     */
    public TreatmentDisposeEventVO saveTreatmentDisposeEventExample(){
        TreatmentDisposeEventAddDTO addDTO = this.getTreatmentDisposeEventAddDTO();
        TreatmentDisposeEventVO treatmentDisposeEventVO = treatmentDisposeEventService.save(addDTO,buildTokenUser());
        return treatmentDisposeEventVO;
    }


}

